import http, {
  wxUtil
} from '../lib/http.js';
import util from '../lib/util.js';
export const evaluateListStore = {
  dataList: []
};
export async function evaluate(e, exeUpdate) { //订单列表/详情  点击评价的handle
  const {
    orderId,
    evaluatorType,
    type
  } = e;
  const initData = await http.get(`${http.serviceName.OrderInner}/orderEvaluate/list`, {
    companyCode: "_",
    orderId
  }, {
    $loading: true
  }).catch(_ => [])
  if (initData.length) {
    evaluateListStore.dataList = initData;
    if (exeUpdate) return;
    if (initData.length === 1 && (e.status>5)) {
      return toEvaluateDetail(initData[0]);
      // 如果只有一条评价  并且点击的订单详情页的查看评价  直接去到评价详情 
      // type 1为结束评价  说明订单已完成  此时次函数的吊用这肯定是  查看评价按钮
    }
    return uni.navigateTo({
      url: util.makeUrlCarryOptions('/pages/zyph/evaluate/evaluateList', e)
    })
  }
  console.log('d丁大信息')
  util.logJson(e)
  uni.navigateTo({
    url: util.makeUrlCarryOptions('/pages/zyph/evaluate/evaluate', {
      mode: "C",
      orderId,
      type,
      evaluatorType
    })
  })
}
export function toEvaluateDetail(item) {
  const {
    id,
    account,
    type,
    replyStatus
  } = item;
  uni.navigateTo({
    url: util.makeUrlCarryOptions('/pages/zyph/evaluate/evaluate', {
      ...util.getPageOptions(),
      id,
      account,
      type,
      replyStatus,
      mode: replyStatus == 1 ? "R" : 'U'
    })
  });
}
